<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	List<TblCheckMend> list = (List<TblCheckMend>)request.getAttribute("list");
	MendForm form = (MendForm)request.getAttribute("command");
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String username = user.getName();
	String userid = user.getUsername();
	String siteid = user.getSiteId();
	String sitename = user.getSiteName();
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月");
	String year_moth = sdf.format(new Date());
%>
<div class="userListWrap">
    <form id="userListForm">
    	<div class="form-item" style="width:180px;">
    		<label for="year_month">补卡年月:</label>
    		<input class="easyui-validatebox"  style="width:80px;height: 22px;" type="text" id="year_month" value="<%=StringUtils.isNotBlank(form.getYear_month())?form.getYear_month():"" %>" name="year_month" onClick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM',maxDate:'%y-%M'})">
        </div>
        <div class="form-item" style="width:180px;">
        	<label for="siteid">所属公司：</label>
			<select  id="siteList" class="easyui-combobox" style="width:100px;" name="siteid" ></select>
		</div>
		<div class="form-item" style="width:180px;">
			<label for="deptid">部门：</label>
			<select id="deptList" class="easyui-combobox" style="width:100px;" name="deptid" ></select>
		</div>
        <div class="form-item" style="width:180px;">
    		<label for="userid">员工编号:</label>
    		<input  class="easyui-validatebox" style="width:100px;height: 22px;"  type="text" id="userid" value="<%=StringUtils.isNotBlank(form.getUserid())?form.getUserid():"" %>" name="userid" >
        </div>     	
        <div class="form-item" >
    		<a href="javascript:XF.Check.personMendListSearch()" class="input-btn-microsoft input-btn-microsoft-24">搜索</a>
        </div>                
    </form>
    <table id="MendUserListTable" class="easyui-datagrid" title="<%=StringUtils.isNotBlank(form.getYear_month())?form.getYear_month():"" %>补卡记录"  >
        <thead>
    		<tr>
    			<th data-options="field:'userid',width:80">员工编号</th>
    			<th data-options="field:'username',width:70">员工姓名</th>
				<th data-options="field:'deptname',width:70">部门</th>
    			<th data-options="field:'checkdate',width:75">考勤日期</th>
    			<th data-options="field:'type',width:50">类型</th>					
				<th data-options="field:'checktime',width:130">补卡时间</th>
				<th data-options="field:'reason',width:100" >补卡原因</th>
				<th data-options="field:'addtim',width:110" >操作时间</th>
				<th data-options="field:'personflag',width:120">操作</th>
				<th data-options="field:'personuser',width:80">人事部审核人</th>
				<th data-options="field:'personremark',width:100">人事部原因</th>
				<th data-options="field:'deptflag',width:80">部门审核状态</th>
				<th data-options="field:'deptuser',width:70">部门审核人</th>
				<th data-options="field:'deptremark',width:100">部门审核原因</th>
				<th data-options="field:'flag',width:80" >员工状态</th>
				<th data-options="field:'remark',width:240" >员工销毁原因</th>
      		</tr>
        </thead>
        <tbody>
        	<%
        		if(list!=null && list.size() > 0){
        			for(TblCheckMend mend:list){
        				%>
       					 <tr s="<%=mend.getId()+"" %>"> 					 	      					 	
       					 	<td><i s="<%=mend.getId()+"" %>"></i><%=(null!=mend.getUserid())?mend.getUserid()+"":"" %></td>
       					 	<td><%=(null!=mend.getUsername())?mend.getUsername()+"":"" %></td>					 	      					 	
       					 	<td><%=(null!=mend.getDeptname())?mend.getDeptname()+"":"" %></td>
       					 	<td><%=mend.getCheckdate()!=null?DateFormatUtils.format(mend.getCheckdate(), "yyyy-MM-dd"):"" %></td>
							<td><%=mend.getType() == 0?"上班卡":"下班卡" %></td>
       					 	<td><%=null!=mend.getChecktime()?mend.getChecktime()+"":"" %></td>
       					 	<td><%=(null!=mend.getReason())?mend.getReason()+"":"" %></td>
       					 	<td><%=null!=mend.getAddtime()?DateFormatUtils.format(mend.getAddtime(), "yyyy-MM-dd HH:mm"):"" %></td>
       					 	<td><div class="innerBtnWrap">
       					 			<%if(mend.getPersonflag()!=null && mend.getDeptflag() !=null){
       					 				if(mend.getPersonflag().equals(0)){%>
	       					 				<a class="inLink" id="e<%=mend.getId() %>" href="javascript:XF.Check.editPersonMend('<%=mend.getId() %>')">修改</a>
											<a class="inLink" id="d<%=mend.getId() %>" href="javascript:XF.Check.deleteMend('<%=mend.getId() %>')">删除</a>
											<a class="inLink" id="p<%=mend.getId() %>" href="javascript:XF.Check.auditPersonMend('<%=mend.getId() %>','2','d')">审核</a>
										<%}else if(mend.getDeptflag().equals(3) && !mend.getPersonflag().equals(3)){%>
											<a class="inLink" id="d<%=mend.getId()+""%>" href="javascript:XF.Check.personDestroyMend('<%=mend.getId() %>')">同意销毁</a>
										<%}else if(mend.getDeptflag().equals(2)  && !mend.getPersonflag().equals(2) && !mend.getPersonflag().equals(1) && !mend.getPersonflag().equals(3) ){%>
											<a class="inLink" id="a<%=mend.getId() %>" href="javascript:XF.Check.auditPersonMend('<%=mend.getId() %>','2','p')">审核通过</a>
											<a class="inLink" id="n<%=mend.getId() %>" href="javascript:XF.Check.noPersonMend('<%=mend.getId() %>')">不通过</a>
										<%}else if(mend.getPersonflag().equals(3)){%>
										<span id='span<%=mend.getId() %>' class="inLink"><font color='#FF0000'>已同意销毁</font></span>	
										<%}else if(mend.getPersonflag().equals(1)){%>
										<span id='span<%=mend.getId() %>' class="inLink"><font color='#FF0000'>审核不通过</font></span>
										<%}else if(mend.getPersonflag().equals(2)&& mend.getFlag().equals(0)){%>
										<span id='span<%=mend.getId() %>' class="inLink">已审核通过</span>
										<a class="inLink" id="cdp<%=mend.getId() %>" href="javascript:XF.Check.auditPersonMend(<%=mend.getId() %>,'4','cdp')">反审核</a>
										<%}else if(mend.getPersonflag().equals(2) && mend.getFlag().equals(2)){%>
										<span  id='span<%=mend.getId() %>'class="inLink">已审核通过</span>
										<a class="inLink" id="cp<%=mend.getId() %>" href="javascript:XF.Check.auditPersonMend(<%=mend.getId() %>,'0','cp')">反审核</a>	
									<%
										}
       					 			}
									%>																		
								</div>
       					 	</td>
       					 	<td><%=(null!=mend.getPersonuser())?mend.getPersonuser()+"":"" %></td>
       					 	<td><%=(null!=mend.getPersonremark())?mend.getPersonremark()+"":"" %></td>
       					 	<td><%if(mend.getDeptflag() !=null && mend.getDeptflag().equals(2)){ %>
       					 			<span>部门已审核</span>
       					 		<%}else if(mend.getDeptflag() !=null && mend.getDeptflag().equals(3)){%>
       					 			<span><font color='#FF0000'>部门已销毁</font></span>
       					 		<%}%>
							</td>       					 	
       					 	<td><%=(null!=mend.getDeptuser())?mend.getDeptuser()+"":"" %></td>
       					 	<td><%=mend.getDeptremark()!=null?mend.getDeptremark()+"":"" %></td>
       					 	<td><%if(mend.getFlag() !=null && mend.getFlag().equals(3)){%>
       					 			<span><font color='#FF0000'>已申请销毁</font></span>
       					 		<%}%>
       					 	</td>       					 	
       					 	<td><%=(null!=mend.getRemark())?mend.getRemark()+"":"" %></td>
			    		</tr>
        				<%
        			}
        		}
        	%>
    	</tbody>
    </table>
    <div class="pagination paginationFixWidth">
		<monggoTag:pagination 
		href="mend_person_search"
		pageSize="<%=form.getPageSize()%>" 
		totalRecord="<%=form.getTotalRecord() %>" 
		currentPage="<%=form.getPageNum() %>">
		</monggoTag:pagination> 
	</div>	
</div>
<script>
$('#MendUserListTable').datagrid();
var sid = '<%=form.getSiteid() %>';
$('#siteList').combobox({
	url:global.contextPath + '/company/siteList',
	valueField:'siteid',
	textField:'sitename',
	panelHeight: 'auto',
	editable:false,
	onSelect:function(record){
		 $('#deptList').combobox('clear'); //清除原来的数据  
        var url = global.contextPath + '/company/datagridDepts?siteid=' + record.siteid;  
        $('#deptList').combobox('reload', url);//联动下拉列表重载 
       },
});
$('#deptList').combobox({
	valueField:'deptid',
	textField:'deptname',								
	url:global.contextPath + '/company/datagridDepts?siteid=' + sid,
	panelHeight: 'auto'
});
$('#siteList').combobox('setValue', '<%=form.getSiteid() %>');
</script>